﻿@model IEnumerable<rateITcd.Models.DishReview>
@using Microsoft.AspNet.Identity;

@{
    ViewBag.Title = "Latest Reviews";
}

<h2>Latest Reviews</h2>


<table class="table">
    <tr>
        <th>
            Reviewer
        </th>
        <th>
            Score
        </th>
        <th>
            Comment
        </th>

        <th>

        </th>     
    </tr>

@foreach (var item in @ViewBag.Reviews) {
    <tr>
        <td>
            @item.Reviewer
        </td>
        <td>
            @item.Score
        </td>
        <td>
            @item.Comment
        </td>
@if (User.IsInRole("Admin") || (User.IsInRole("User") && @item.Reviewer == User.Identity.GetUserName()))
{        <td>
            @Html.ActionLink("Edit", "Edit", "DishReview", new { id=item.Id }, "") |
            @Html.ActionLink("Delete", "Delete", "DishReview", new { id=item.Id }, "")
        </td>
}
else
{
    <td></td>
}
    </tr>
}

</table>
